﻿using System.Collections.Generic;
using UnityEngine;

/*�ųǽ���*/

public class Test_Random : MonoBehaviour
{
    private void Update1()
    {
        if (Input.GetKeyDown(KeyCode.A))
        {
            int n = Random.Range(0, 5);//左闭右开  取不到5
            print(n);
        }
    }

    //练习:按空格产生方块  让X轴的位置在0，10之前随机
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
            float x = Random.Range(0, 10);
            go.transform.position = new Vector3(x, x, 1);
            go.GetComponent<MeshRenderer>().material.color = Random.ColorHSV();
        }
    }
}